package com.xdy.redis.demo;

import redis.clients.jedis.Jedis;

/**
 * @Author: XDY.
 * @Email: 2280944114@qq.com
 * @CreateTime: 2023-05-07  15:23
 * @Description: Jedis客户端测试
 * @Version: 1.0
 */
public class JedisDemo {
    public static void main(String[] args) {
        //创建客户端
        Jedis jedis = new Jedis("192.168.64.131", 6379);
        //设置连接密码
        jedis.auth("07032539");
        //测试连接
        System.out.println(jedis.ping());
        //添加string
        jedis.set("k1","v1");
        System.out.println(jedis.get("k1"));
        //添加哈希
        jedis.hset("h1","name","许琳康");
        jedis.hset("h1","age","20");
        System.out.println(jedis.hgetAll("h1"));
        //添加list
        jedis.lpush("l1","11","22","33","44","55");
        System.out.println(jedis.lrange("l1", 0, -1));
        //添加set
        jedis.sadd("s1","1","1","2","2","3","3");
        System.out.println(jedis.smembers("s1"));
        //添加sorted-set
        jedis.zadd("z1",90,"A");
        jedis.zadd("z1",80,"B");
        jedis.zadd("z1",70,"C");
        jedis.zadd("z1",60,"D");
        System.out.println(jedis.zrange("z1", 0, -1));
    }
}
